<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    姓名:<input type="text" class="myinput" /> <button class="btn">确定</button>
    <script>
      // 获取输入框里的值  元素.value;
      var ele = document.querySelector(".myinput");
      var btn = document.querySelector(".btn");
      btn.onclick = function () {
        console.log(ele.value);
      };
    </script>
  </body>
</html>
